package com.example.wei.mvp.api.support;

import com.example.wei.mvp.util.L;
import com.example.wei.mvp.util.SPUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by Administrator on 2017/11/30 0030.
 */

public class AddCookiesInterceptor implements Interceptor {


    @Override
    public Response intercept(Chain chain) throws IOException {
        Request.Builder builder = chain.request().newBuilder();
        String sessionid = (String) SPUtils.get("sessionid", "");
        builder.addHeader("Cookie", sessionid);
        L.d("OkHttp", "Adding Header: " + sessionid);
        return chain.proceed(builder.build());
    }


}
